#include "samplerecord.h"

namespace sampler {
static SNDFILE * openSoundFile(const QString & name)
{
    SF_INFO sfinfo;
    SNDFILE * soundFile;
    if( !(soundFile =
          sf_open(name.toAscii().data(), SFM_READ, &sfinfo)))
        gl::log("can not open sound file");
    return soundFile;
}
}

SampleRecord::SampleRecord (const Note & bottomLeft,
                                 const Note & upperRight,
                                 const QString & file_name):
    note_left_(bottomLeft),
    note_right_(upperRight),
    pan_(0.5),
    file_name_(file_name),
    file_(sampler::openSoundFile(file_name)){}

SampleRecord::~SampleRecord() {
    if (file_ != NULL) sf_close(file_);
}
